public class ViolentSolution {
    public int findMaxLength(int[] nums) {
        int len = nums.length;
        int ret = 0;
        for (int i = 0; i < len; i++) {
            int count0 = 0, count1 = 0;
            for (int j = i; j < len; j++) {
                if (nums[j] == 0) {
                    count0++;
                } else {
                    count1++;
                }
                if (count0 == count1) {
                    ret = Math.max(ret, count0 + count1);
                }
            }
        }
        return ret;
    }
}
